(function(){var e=window.BX;if(e.Access)return;e.Access={bInit:false,waitDiv:null,waitPopup:null,bDialogLoaded:false,selectedProvider:"",obSelected:{},obCnt:{__providers_cnt:0},obAlreadySelected:{},obSelectedBind:{},showSelected:false,popup:null,callback:null,obProviderNames:{},arParams:{}};e.Access.Init=function(s){if(s)e.Access.arParams=s;if(e.Access.bInit)return;e.Access.bInit=true;e.ready(e.delegate(function(){e.Access.popup=e.PopupWindowManager.create("BXUserRights",null,{autoHide:false,zIndex:0,offsetLeft:0,offsetTop:0,draggable:{restrict:true},closeByEsc:true,titleBar:e.message("js_access_title"),contentColor:"white",contentNoPaddings:true,closeIcon:true,buttons:[new e.PopupWindowButton({text:e.message("js_access_select"),className:"popup-window-button-accept",events:{click:function(){e.Access.SaveLRU();e.Access.SaveSelected();if(e.Access.callback)e.Access.callback(e.Access.obSelected);this.popupWindow.close()}}}),new e.PopupWindowButtonLink({text:e.message("js_access_close"),className:"popup-window-button-link-cancel",events:{click:function(){this.popupWindow.close()}}})],content:'<div class="access-container"></div>',events:{onAfterPopupShow:function(){if(!e.Access.bDialogLoaded){e.Access.showWait(this.contentContainer);e.ajax.post("/bitrix/tools/access_dialog.php",{lang:e.message("LANGUAGE_ID"),site_id:e.message("SITE_ID")||"",arParams:e.Access.arParams},e.delegate(function(s){this.setContent(s);e.Access.closeWait();e.Access.bDialogLoaded=true;if(e.Access.showSelected){for(var c in e.Access.obAlreadySelected){if(typeof e.Access.obAlreadySelected[c]=="object"){e.Access.AddSelection(e.Access.obAlreadySelected[c])}}}},this))}else{if(e.Access.showSelected){for(var s in e.Access.obAlreadySelected){if(typeof e.Access.obAlreadySelected[s]=="object"){e.Access.AddSelection(e.Access.obAlreadySelected[s])}}}}e.onCustomEvent(e.Access,"onAfterPopupShow",[])},onPopupClose:function(){e.Access.ClearSelection()}}})},this))};e.Access.ShowForm=function(s){if(!s.bind)s.bind="bind";e.Access.bind=s.bind;e.Access.showSelected=s.showSelected===true;if(e.Access.obSelectedBind[s.bind])e.Access.obAlreadySelected=e.Access.obSelectedBind[s.bind];else e.Access.obAlreadySelected={};e.Access.callback=s.callback;e.Access.popup.show()};e.Access.showWait=function(s){e.Access.waitDiv=e.Access.waitDiv||s;s=e(s||e.Access.waitDiv);if(!e.Access.waitPopup){e.Access.waitPopup=new e.PopupWindow("ur_wait",s,{autoHide:true,lightShadow:true,content:e.create("DIV",{props:{className:"ur-wait"}})})}else{e.Access.waitPopup.setBindElement(s)}var c=s.offsetHeight,t=s.offsetWidth;if(c>0&&t>0){e.Access.waitPopup.setOffset({offsetTop:-parseInt(c/2+15),offsetLeft:parseInt(t/2-15)});e.Access.waitPopup.show()}return e.Access.waitPopup};e.Access.closeWait=function(){if(e.Access.waitPopup)e.Access.waitPopup.close()};e.Access.SelectProvider=function(s){if(e.Access.selectedProvider!=""){e("access_btn_"+e.Access.selectedProvider).className="access-provider-button";e("access_provider_"+e.Access.selectedProvider).style.display="none"}e("access_btn_"+s).className="access-provider-button access-provider-button-selected";e("access_provider_"+s).style.display="";e.Access.selectedProvider=s;e.onCustomEvent(e.Access,"onSelectProvider",[{provider:s}])};e.Access.AddSelection=function(s){if(!s.provider){return}if(!e.Access.obSelected[s.provider]){e.Access.obSelected[s.provider]={};e.Access.obCnt[s.provider]=0;e.Access.obCnt.__providers_cnt++}if(!e.Access.obSelected[s.provider][s.id]){e.Access.obSelected[s.provider][s.id]=e.clone(s);e.Access.obCnt[s.provider]++;e("access_selected_title").style.display="none";e("access_selected_provider_"+s.provider).style.display="";e("access_selected_items_"+s.provider).appendChild(e.create("div",{props:{className:"bx-finder-box-selected-item",id:"access_selected_item_"+s.id},html:'<a href="javascript:void(0);" onclick="BX.Access.RemoveSelection(\''+s.provider+"', '"+s.id+'\')" class="bx-finder-box-selected-item-icon"></a><span class="bx-finder-box-selected-item-text">'+e.util.htmlspecialchars(s.name)+"</span>"}));e("access_sel_count_"+s.provider).innerHTML="("+e.Access.obCnt[s.provider]+")"}};e.Access.RemoveSelection=function(s,c){delete e.Access.obSelected[s][c];e.Access.obCnt[s]--;var t=e("access_selected_item_"+c);t.parentNode.removeChild(t);if(e.Access.obCnt[s]==0){delete e.Access.obSelected[s];e.Access.obCnt.__providers_cnt--;e("access_selected_provider_"+s).style.display="none";if(e.Access.obCnt.__providers_cnt==0)e("access_selected_title").style.display=""}else{e("access_sel_count_"+s).innerHTML="("+e.Access.obCnt[s]+")"}e.onCustomEvent(e.Access,"onDeleteItem",[{provider:s,id:c}])};e.Access.ClearSelection=function(){for(var s in e.Access.obSelected)for(var c in e.Access.obSelected[s])e.Access.RemoveSelection(s,c);e.Access.obSelected={}};e.Access.SaveLRU=function(){e.ajax.post("/bitrix/tools/access_dialog.php",{LRU:e.Access.obSelected,mode:"save_lru",sessid:e.bitrix_sessid()})};e.Access.SaveSelected=function(){if(e.Access.showSelected||!e.Access.obSelectedBind[e.Access.bind])e.Access.obSelectedBind[e.Access.bind]={};for(var s in e.Access.obSelected){for(var c in e.Access.obSelected[s]){if(e.Access.showSelected)e.Access.obSelectedBind[e.Access.bind][c]={id:c,provider:s,name:e.Access.obSelected[s][c].name};else e.Access.obSelectedBind[e.Access.bind][c]=true}}};e.Access.SetSelected=function(s,c){if(!c)c="bind";e.Access.obSelectedBind[c]=s};e.Access.DeleteSelected=function(s,c){if(!c)c="bind";if(e.Access.obSelectedBind[c]&&e.Access.obSelectedBind[c][s]){delete e.Access.obSelectedBind[c][s]}};e.Access.GetProviderName=function(s){if(e.Access.obProviderNames[s])return e.Access.obProviderNames[s].name;return""};e.Access.GetProviderPrefix=function(s,c){if(e.Access.obProviderNames[s]){var t=e.Access.obProviderNames[s]["prefixes"];for(var o in t){var i=new RegExp(t[o]["pattern"]);if(i.test(c)){return t[o]["prefix"]}}return e.Access.obProviderNames[s].name}return""}})();
//# sourceMappingURL=core_access.map.js